
define([
	'vue',
	'config',
	'common',
	'moment'
	],function(Vue,config,utils,moment){
	'use strict';

	var consumerAuditView=new Vue({
		el:'#app',
		data:{
			id:'',
			items:{},
			nopassType:'',
			statusType:'',
			auditOpinion:'', //不通过反馈信息
			Checking:'',	 //审核状态

			PhotoBrowser:'',	//图片浏览器
			backType:''
		},
		filters:{
			moment:function(date){
				var Date = moment(date*1000).format('YYYY-MM-DD HH:mm:ss');
				return Date;
			}
		},
		created:function(){
			utils.userToken();

			var _this = this;
			_this.id = utils.getQueryVariable('id');
			utils.ajax(utils.getWebUrl('declaration/get'),{
				id: _this.id
			},'POST',function(res){
				// /console.log(res)
				//console.log(res.data.status);
				_this.auditOpinion = res.data.orderAudit.auditOpinion ? res.data.orderAudit.auditOpinion:null;
				_this.items = res.data;

				//判断status
				var status = res.data.status;
				//判断审核未通过类型
				var nopassType ;
				var transferVoucher = res.data.transferVoucher;
				if((status === '3'||status === '7')&&(!transferVoucher)){
					nopassType = '0'; //未上传汇款凭证
				}else if((status === '3'||status === '7')&&(transferVoucher)){
					nopassType = '1'; //已上传汇款凭证
				}
				_this.nopassType = nopassType;

				
				
				if(status === '1'||nopassType === '0'){
					//未上传汇款凭证
					_this.statusType = '0';
				}

				if(status === '5'){
					//已上传汇款凭证审核中
					_this.statusType = '1';
				}


				if((status === '3'||status ==='7')&&(transferVoucher)){
					//已上传汇款凭证审核未通过
					_this.statusType = '2';
				}


				//判断审核状态
				if(status === '1'||status === '5'){
					_this.Checking = 'check';
				}
				
				if(status === '3'||status === '7'){
					_this.Checking = 'nopass';
				}

				//console.log(_this.statusType)

			},function(){
				$('.DataLoading').show();
			},function(){
				$('.DataLoading').hide();
			})

			_this.backType = utils.getQueryVariable('backType');
			// window.addEventListener('popstate',function() {
	  //      		if(_this.backType === "1"){
	  //      			var userTypeId =utils.getData('userTypeId');
			// 		if(userTypeId == 4){
			// 			window.location.href='userInfo.html';
			// 		}else{
			// 			window.location.href='shopInfo.html';
			// 		}
	  //      		}else{
	  //      			window.location.href = "expensesRecord_shop.html";
	  //      		}
		 //    })
		},
		methods:{
			back:function(){
				if(this.backType === "1"){
	       			var userTypeId =utils.getData('userTypeId');
					if(userTypeId == 4){
						window.location.href='userInfo.html';
					}else{
						window.location.href='shopInfo.html';
					}
	       		}else{
	       			window.location.href = "expensesRecord_shop.html";
	       		}
			},
			AddPhotoBrowser:function(event){
				//console.log($(event.currentTarget))
				var $target = $(event.currentTarget);
				var img = $(event.currentTarget).attr('src')
				var myApp = new Framework7();
				this.PhotoBrowser = myApp.photoBrowser({
				    zoom: 400,
				    photos: [img],
				    backLinkText: '关闭',
				    loop: false,
				    ofText:'/',
				    expositionHideCaptions: true
				});
				this.PhotoBrowser.open(); 
			},
			toRepeatSubmit:function(){
				if(this.nopassType === '0'){
					window.location.href="consumptionCertificate.html?id="+this.id;
				}else if(this.nopassType === '1'){
					window.location.href="remittanceVoucher.html?id="+this.id;
				}
			}
		}
	})

	return consumerAuditView;
});